<?php

	$connect = mysql_connect("localhost","root","");
	$selectSQL = mysql_select_db("new");
	mysql_query("set names utf8");
	
	$attName = $_POST['attName'];
	$attHeadUrl = $_POST['attHeadUrl'];
	$attCla = $_POST['attCla'];
	$attUser = $_POST['attUser'];
	$loveId = $_POST['loveId'];
	
	
	
	$sql = "SELECT * FROM wangLove WHERE lovename = '{$attName}' AND name = '{$attUser}'";
	$result = mysql_query($sql);
	if(mysql_affected_rows()>0){
		$sql = "DELETE FROM wangLove WHERE lovename = '{$attName}' AND name = '{$attUser}'";
		$result = mysql_query($sql);
		if(mysql_affected_rows()>0){
			$arr = array('msg' => '+关注','error'=>0 );
			echo json_encode($arr);
			
		}
	}else{
		$sql = "INSERT INTO wangLove(id,lovename,loveheadimg,lovepro,name,loveID) VALUES (NULL,'{$attName}','{$attHeadUrl}','{$attCla}','{$attUser}','{$loveId}')";
		$result = mysql_query($sql);
		if(mysql_affected_rows()>0){
			$arr = array('msg' =>'您已关注' ,'error'=>1 );
			echo json_encode($arr);
		}
	}
	
	
?>